import { query } from '../services/material';

export default {
  namespace: 'material',
  state: {},
  effects: {
    *getMaterial({ payload }, { call, put }) {
      const { data: { message, material_warehouse, material_funds } } = yield call(query);
      message === 'success' ? payload.success() : payload.failed();
      yield put({ type: 'update', data: { material_warehouse, material_funds } });
    }
  },
  reducers: {
    update(state, action) {
      return { ...state, data: action.data }
    }
  }
}